<?PHP


global $conf;
$music=new music;
//check if valid action
//$view=FALSE;
if($conf->qm[0]=='media' && !empty($conf->qm[1]))
{
	

	$music->where['id']=$conf->qm[1];
	$music->get_music();
	if(!empty($music->data))
	{
		$media=current($music->data);
		$show=TRUE;
		
	}
}

if($show)
{
	$p_content=new content;
	$playlist=new music;
	$more=new music;
	$more->where['artist']=$media['artist'];
	$more->where['album']=$media['album'];
	$more->get_music();
	$album_music=$more->data;
	
	$conf->page_render='assets/pages/media.php';
	$conf->style['masthead']="Pinoytuner Music";
		$conf->meta['page_title']=$media['name']." by ".$media['artist']." on ".$conf->a['site-name'];
		$conf->meta['Title']=$media['name']." by ".$media['artist']." on ".$conf->a['site-name'];
		
		$conf->a['img-src']=ap('pinoytuner-icon.jpg');
		$conf->meta['Description']="Pinoytuner serves ".$media['name']." by ".$media['artist'];
		$conf->meta['SearchDescription']="Pinoytuner serves ".$media['name']." by ".$media['artist'];
		$conf->meta['SearchTitle']=$media['name']." by ".$media['artist']." on ".$conf->a['site-name'];
	//get playlists
	
	$w[0]='media';
	$w[1]=$media['id'];
	$w[2]='=';
	$where[]=$w;

	$playlists=get_sql('playlist_media','id',$where,NULL);
		unset($where);
	//get content_video
	
	foreach($playlists as $x)
	{
		$w[0]='playlist';
		$w[1]=$x['playlist'];
		$w[2]='=';
		$where[]=$w;
	
		$content_video=get_sql('content_video','id',$where,NULL);
		$cv[]=current($content_video);
		unset($where);
	}
	
	foreach($cv as $x)
	{
		$w[0]='id';
		$w[1]=$x['id'];
		$w[2]='=';
		$where[]=$w;
		$w[0]='end';
		$w[1]=date("Y-m-d");
		$w[2]='>=';
		$where[]=$w;
		if(!$conf->test_content)
		{
			$w[0]='status';
			$w[1]='enabled';
			$w[2]='=';
			$where[]=$w;
			
				$w[0]='start';
				$w[1]=date("Y-m-d");
				$w[2]='<=';
				$where[]=$w;

		
		}
	
		$content_items=get_sql('content','id',$where,NULL);
		$ci[]=current($content_items);
		unset($where);
	
	}
	
	
	//print_r($ci);
}
else
{
	$conf->page_render='admin/e/404.php';
	$conf->advertise=false;
}

//print_r($media);

?>